package com.res.exam;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.res.demo.R;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class HttpConnectionActivity extends Activity {
	private static final String TAG = "HttpConnectionActivity";

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.table);

		HttpConnectionManager manager = new HttpConnectionManager();

		List<NameValuePair> params = new ArrayList<NameValuePair>();
		// params.add(new BasicNameValuePair("ProductName", "sou01"));
		Log.v(TAG, "TEST");
		manager.sentRequest("http://127.0.0.1/diplom/city.php", params,
				new OnHttpConnectionLoad() {

					public void onHttpConnectionExecuted(String response) {
						// TODO Auto-generated method stub
						Log.d("RESPONSE", "no1 " + response);
						JSONObject a;
						try {
							a = new JSONObject(response);
							String k = a.getString("ProductName");
							TextView s = (TextView) findViewById(R.id.textView2);
							JSONArray aee = a.getJSONArray("data");
							for(int i = 0; i<aee.length();i++){
								JSONObject ob = aee.getJSONObject(i);
								
							}
							s.setText(k);
						} catch (JSONException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}

					}
				});

	}
}